﻿<%@ Page Title="" Language="C#" MasterPageFile="~/LeftColumn.master" AutoEventWireup="true" CodeBehind="SupplyProducts.aspx.cs" Inherits="Supermarket.Web.CashierPages.SupplyProducts" %>
<asp:Content ID="Content1" ContentPlaceHolderID="RightContent" runat="server">

    <asp:MultiView ID="MultiViewSupplies" runat="server" ActiveViewIndex="0">
        <asp:View ID="ViewProducts" runat="server">
            <h2>Зареждане на стоки</h2>
            <div style="float:right; display:block">
                <asp:LinkButton ID="LinkButtonSupply" Text="Плати избраните стоки" 
                    runat="server" onclick="LinkButtonSupply_Click" />
            </div>
            <br /><br />
            <asp:GridView ID="GridViewProducts" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" DataSourceID="odsProducts" BackColor="#DEBA84" 
                BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                CellSpacing="2" onrowcommand="GridViewProducts_RowCommand" 
                DataKeyNames="ProductId">
                <Columns>
                    <asp:BoundField DataField="ProductName" HeaderText="Продукт" ReadOnly="True" 
                        SortExpression="ProductName" />
                    <asp:BoundField DataField="ProductPrice" HeaderText="Цена" ReadOnly="True" 
                        SortExpression="ProductPrice" DataFormatString="{0:0.00}" />
                    <asp:BoundField DataField="MeasureCode" HeaderText="Код" ReadOnly="True" 
                        SortExpression="MeasureCode" />
                    <asp:BoundField DataField="CompanyName" HeaderText="Производител" 
                        ReadOnly="True" SortExpression="CompanyName" />
                    <asp:BoundField DataField="CategoryName" HeaderText="Категория" ReadOnly="True" 
                        SortExpression="CategoryName" />
                    <asp:BoundField DataField="InStock" HeaderText="Наличност" ReadOnly="True" 
                        SortExpression="InStock" />
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButtonSupply" Text="Зареди" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#FFF1D4" />
                <SortedAscendingHeaderStyle BackColor="#B95C30" />
                <SortedDescendingCellStyle BackColor="#F1E5CE" />
                <SortedDescendingHeaderStyle BackColor="#93451F" />
            </asp:GridView>
        </asp:View>
        <asp:View ID="ViewBuyProduct" runat="server"  >
            <asp:HiddenField ID="hfId" runat="server" />
            <table>
                <thead>
                    <tr>
                        <th colspan="2">
                            Зареждане на стоки
                        </th>
                    </tr>
                </thead>
                <tr>
                    <td>
                        <span>Продукт:</span>
                    </td>
                    <td>
                        <asp:Label ID="LabelProductName" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <span>Цена:</span>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBoxProductPrice" Width="50" runat="server" /><span> лв.</span>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPrice" runat="server" 
                                    ErrorMessage="Въведете цена." 
                                    CssClass="failureNotification" 
                                    ControlToValidate="TextBoxProductPrice" Display="Dynamic">*</asp:RequiredFieldValidator>
                        <asp:CompareValidator ID="CompareValidatorTypeCheck" runat="server" 
                                    ErrorMessage="Въведете коректна цена (използвайте запетайка)" 
                                    Type="Currency" 
                                    CssClass="failureNotification" 
                                    ControlToValidate="TextBoxProductPrice" Display="Dynamic" 
                                    Operator="DataTypeCheck">*</asp:CompareValidator>
                        <asp:CustomValidator runat="server" id="CustomValidator"
                                    ControlToValidate="TextBoxProductPrice"
                                    OnServerValidate="PriceProductCheck"
                                    CssClass="failureNotification"
                                    Text="*"
                                    ErrorMessage="Цената е по-голяма от тази на която се продава!" Display="Dynamic" />
            <br />
                    </td>
                </tr>
                <tr>
                    <td>
                        <span>Количество:</span>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBoxQuantity" Width="50" runat="server" />
                        <asp:Label ID="LabelMeasureCode" runat="server" />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Въведете цяло или реално число с десетична запетая."
                                    Text="Въведете цяло или реално число с десетична запетая." CssClass="failureNotification"
                                    ControlToValidate="TextBoxQuantity" 
                                    ValidationExpression="(\d+(,\d{1,3})?){1}" 
                                    Display="Dynamic">*</asp:RegularExpressionValidator>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorQuantity" runat="server" ErrorMessage="Въведете количество."
                                    Text="Въведете количество." CssClass="failureNotification" 
                                    ControlToValidate="TextBoxQuantity">*</asp:RequiredFieldValidator>                        
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="ButtonBuy" runat="server" Text="Купи" OnClick="ButtonBuy_Click" />
                    </td>
                    <td>
                        <asp:Button ID="ButtonCancel" runat="server" Text="Отказ" OnClick="ButtonCancel_Click"
                            CausesValidation="False" />
                    </td>
                </tr>
            </table>           
            <asp:ValidationSummary ID="ValidationSummarySupply" runat="server" 
                CssClass="failureNotification" />
            <asp:Label ID="LabelError" Text="" runat="server" />
            <br />
            <asp:LinkButton ID="LinkButtonForceSupply" Text="Купи въпреки цената" 
                runat="server" Visible="false" onclick="LinkButtonForceSupply_Click" />
        </asp:View>
    </asp:MultiView>
    <asp:ObjectDataSource ID="odsProducts" runat="server" 
        SelectMethod="GetAllProducts" TypeName="Supermarket.Bll.ProductManager"></asp:ObjectDataSource>

</asp:Content>
